package cn.com.scitc.licenseplateback.model;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "j_user_tokens", schema = "CubeLibrary", catalog = "")
public class JUserTokensEntity {
    private int id;
    private String userId;
    private String token;
    private String logintime;
    private int expires;

    public JUserTokensEntity() {
    }

    public JUserTokensEntity(int id, String userId, String token, String logintime, int expires) {
        this.id = id;
        this.userId = userId;
        this.token = token;
        this.logintime = logintime;
        this.expires = expires;
    }

    @Id
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "user_id", nullable = false, length = 32)
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "token", nullable = false, length = 40)
    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    @Basic
    @Column(name = "logintime", nullable = false)
    public String getLogintime() {
        return logintime;
    }

    public void setLogintime(String logintime) {
        this.logintime = logintime;
    }

    @Basic
    @Column(name = "expires", nullable = false)
    public int getExpires() {
        return expires;
    }

    public void setExpires(int expires) {
        this.expires = expires;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        JUserTokensEntity that = (JUserTokensEntity) o;
        return id == that.id &&
                expires == that.expires &&
                Objects.equals(userId, that.userId) &&
                Objects.equals(token, that.token) &&
                Objects.equals(logintime, that.logintime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, userId, token, logintime, expires);
    }
}
